package com.longmao.edustatistics.controller;


import com.longmao.commonutils.R;
import com.longmao.edustatistics.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author longmao
 * @since 2022-03-01
 */
@RestController
@RequestMapping("/edusta/daily")
//@CrossOrigin
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService statisticsDailyService;

    /**
     * 统计某天注册人数
     * @param day
     * @return
     */
    @PostMapping("/createStatisticsByDate/{day}")
    public R createStatisticsByDate(@PathVariable String day) {
        statisticsDailyService.createStatisticsByDay(day);
        return R.ok();
    }

    @GetMapping("/showData/{begin}/{end}/{type}")
    public R showData(@PathVariable String begin,@PathVariable String end,@PathVariable String type){
        Map<String, Object> map = statisticsDailyService.showData(begin, end, type);
        return R.ok().data(map);
    }
}

